package com.writer_;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;

/**
 * @author Vhong
 * @version 1.0
 */
public class BufferedWriter_ {
    public static void main(String[] args) throws IOException {
        String filePath = "e:\\a.txt";
        BufferedWriter bufferedWriter = null;

        //1.new FileWriter(filePath,true)表示以追加的方式写入
        //2.new FileWriter(filePath),表示以覆盖的方式写入
        bufferedWriter = new BufferedWriter(new FileWriter(filePath));
        bufferedWriter.write("hello1");
        bufferedWriter.newLine();//传入一个和系统相关的换行
        bufferedWriter.write("hello2");
        bufferedWriter.newLine();
        bufferedWriter.write("hello3");
        bufferedWriter.newLine();


        //说明：关闭外层流即可，传入的 new FileWriter(filePath)
        bufferedWriter.close();
    }
}
